$(document).ready(function() {

	var nextImageNum = 2;
	var pause = false;
	var oldNum = nextImageNum;
	
	function imageInformation(x){
		switch(x){
			case 1: return "Tacos by Shelley";
			case 2: return "Strawberry Salad by Shelley";
			case 3: return "Turkey Burger with Guacamole and Farfalle Pasta Salad with Spinach by Shelley";
			case 4: return "Quinoa Crasin Salad by Shelley";
			case 5: return "Homemade Granola Treat by Shelley";
		}
		
		return "";
	}
	
	$(".circle").mouseover(function(){
		pause = true;
		var id = $(this).attr("id");
		
		oldNum = nextImageNum;
		
		switch(id){
			case "b1": nextImageNum = 1; break;
			case "b2": nextImageNum = 2; break;
			case "b3": nextImageNum = 3; break;
			case "b4": nextImageNum = 4; break;
			case "b5": nextImageNum = 5; break;
		}
		
		if(oldNum == nextImageNum) return;
		changeImage();
		
	});
	
	$(".circle").mouseout(function(){
		pause = false;
		
		if(oldNum == nextImageNum) return;
		
		nextImageNum = oldNum;
		changeImage();
	});

	function changeImage(){
	
	if(pause) return;
	
	$("#bannerImage").fadeOut('slow',function(){
	
		if(nextImageNum > 5) nextImageNum = 1;
		
		var nextImageName = "images/banner/" + nextImageNum + ".png";
	
		$(this).load(function() {$(this).fadeIn(); });
		$(this).attr("src", nextImageName);
		
		$("#bannerText").html(imageInformation(nextImageNum));
		
		var previousNumber = nextImageNum - 1;
		if(previousNumber < 1) previousNumber = 5;
		
		var dotF = "#b" + nextImageNum;
		var dotE = "#b" + previousNumber;
		
		$(dotF).attr("src", "images/circlefill.png");
		$(dotE).attr("src", "images/circle.png");
		
		nextImageNum++;
	});
	
	}

	setInterval(changeImage, 6000);
	
});